package com.fallwings.Controller;

import com.fallwings.Service.ICartoonService;
import com.fallwings.domain.Cartoon;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Killer on 2016/1/5.
 */
@Controller
@RequestMapping(value = "/Cartoon")
public class CartoonController {
    @Resource(name = "CartoonService")
    private ICartoonService iCartoonService;

    /**
     * 获取每日更新列表
     * @param date 更新时间
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public ResponseEntity<List<Cartoon>> select_Cartoon_Update_Form(String date){
        List<Cartoon> list=iCartoonService.select_Cartoon_Update_Form(date);
        return  new ResponseEntity<List<Cartoon>>(list, HttpStatus.MULTI_STATUS.OK);
    }

    /**
     * 按照条件获取资源
     * @param top   获取资源的数目
     * @param Name  资源的名字
     * @param Area  资源的地区
     * @param Type  资源的分类
     * @param order 排序顺序：0随机，1按点击量顺序，2按点击量倒叙
     * @param star  排序初始值
     * @param size  排序大小
     * @return
     */
    @RequestMapping(method = RequestMethod.GET,value = "/getList")
    public ResponseEntity<List<Cartoon>> select_Cartoon_List(Integer top,String Name,String Area,String Type,Integer order,Integer star,Integer size){
        Map<String,Object> map=new HashMap<>();
        map.put("top",top);
        map.put("Name",Name);
        map.put("Area",Area);
        map.put("Type",Type);
        map.put("order",order);
        map.put("star",star);
        map.put("size",size);
        List<Cartoon> list=iCartoonService.queryList(map);
        return new ResponseEntity<List<Cartoon>>(list,HttpStatus.OK);
    }

    /**
     * 获取Cartoon的分类列表
     * @param size  获取分类的数目
     * @return
     */
    @RequestMapping(method = RequestMethod.GET,value = "/getType")
     public ResponseEntity<List<String>> select_Cartoon_TypeList(Integer size){
         List<String> list=iCartoonService.queryType(size);
         return new ResponseEntity<List<String>>(list,HttpStatus.OK);
     }
}
